<%--
  Created by IntelliJ IDEA.
  User: wenze-zero
  Date: 2021-06-03-003
  Time: 下午 03:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <table border="1">
        <tr><th>编号</th><th>用户名</th><th>密码</th></tr>
<%
    Class.forName ("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai", "root", "20010812");
    out.println("数据库链接成功"+"<br>");
    Statement stm=conn.createStatement();
    String sql="select * from student";
    ResultSet rs=stm.executeQuery(sql);
    %>
<%    while(rs.next()){
        %>
        <tr>
            <td><%=rs.getInt("id") %></td>
            <td><%=rs.getString("username") %></td>
            <td><%=rs.getString("password") %></td>
        </tr>
        <%
    }
    stm.close();
    conn.close();
%>
    </table>
</body>
</html>